<template>
	<view class="user clearfix  bg-shop hv100">
		<cu-custom bgColor="bg-white " isBack>
			<block slot="content">设置</block>
		</cu-custom>
		<view class="flex align-center justify-between px15 f16 bg-white mt5 py20" @click="pushPage('/pages/user/paypwd')">
			<view class="flex align-center">修改支付密码</view>
			<text class="cuIcon-right"></text>
		</view>
		<view class="flex align-center justify-between px15 f16 bg-white mt1 py20" @click="pushPage('/pages/user/password')">
			<view class="flex align-center">修改登录密码</view>
			<text class="cuIcon-right"></text>
		</view>
		<view class="py15 px15 text-info ">添加提现方式</view>
		<view class="flex align-center justify-between px15 f16 bg-white py20" @click="pushPage('/pages/Receivables/bank/index')">
			<view class="flex align-center">银行卡</view>
			<text class="cuIcon-right"></text>
		</view>
		<view class="flex align-center justify-between px15 f16 bg-white mt1 py20" @click="payzfb">
			<view class="flex align-center">支付宝</view>
			<text class="cuIcon-right"></text>
		</view>
		<view class="flex align-center justify-between px15 f16 bg-white mt1 py20" @click="paywx">
			<view class="flex align-center">微信</view>
			<text class="cuIcon-right"></text>
		</view>
		<view class="py15 px15 text-info">第三方账号</view>
		<view class="flex align-center justify-between px15 f16 bg-white py20" @click="userweixin">
			<view class="flex align-center">微信</view>
			<text class="cuIcon-right"></text>
		</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
	data() {
		return {
			iswx:0,
			isairpay:0,
			paylist:[],
			iswxair:false
		}
	},
	computed: {
		...mapState(['userInfo','baseURL'])
	},
	onShow() {
		this.getData()
	},
	methods: {
		...mapActions(['logout','getUser']),
		async getData() {
			let {
				data
			} = await this.$http.post('user.paylist')
			this.paylist=data
			this.isairpay=this.paylist.findIndex(item => {
				return item.status ==1
			})
			this.iswx=this.paylist.findIndex(item => {
				return item.status ==2
			})
			this.iswxair=true
		},
		payzfb(){
			if(this.iswxair){
				if(this.isairpay==-1){
					this.pushPage('/pages/Receivables/airpay')
				}else{
					this.pushPage('/pages/Receivables/payindex?type='+'0'+'&airindex='+this.isairpay)
				}
			}
		},
		paywx(){
			if(this.iswxair){
				if(this.iswx==-1){
					this.pushPage('/pages/Receivables/wxpay')
				}else{
					this.pushPage('/pages/Receivables/payindex?type='+'1'+'&wxindex='+this.iswx)
				} 
			}
		},
		userweixin(){
			// if(this.userInfo.wxBind!=0){
			// 	uni.showToast({
			// 		title:'您已经绑定过微信了',
			// 		icon:'none'
			// 	})
			// 	return false
			// }else{
			// 	let _this = this;
			// 	uni.login({
			// 	    provider: 'weixin',
			// 	    success: function (loginRes) {
			// 		    uni.getUserInfo({
			// 			  provider: 'weixin',
			// 			  success: function (infoRes) {
			// 				//console.log('用户昵称为：' + infoRes.userInfo.nickName);
			// 				//console.log('用户ID：' + infoRes.userInfo.openId);
			// 				//console.log('用户头像：' + infoRes.userInfo.avatarUrl);
			// 				_this.weixinid=infoRes.userInfo.openId
			// 				_this.bangweixin()
			// 			  }
			// 			});
			// 	    },
			// 		fail: function (loginRes) {
			// 	       console.log(loginRes.authResult);
			// 	    },
			// 	});
			// }
			
		},
	}
}
</script>

<style lang="less">
.mt1s{
	margin-top: 1rpx;
}
.set-button{
	width: calc(100% - 60rpx);
	margin-left: 30rpx;
	height: 102rpx;
	background-color:#FE4725;
	color: #FFFFFF;
	border-radius: 40rpx;
	position: fixed;
	bottom: 40rpx;
}
</style>
